package com.itheima.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.mapper.VipMapper;
import com.itheima.pojo.PageBean;
import com.itheima.pojo.Vip;
import com.itheima.service.VipService;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

@Service
public class VipServiceImpl implements VipService {

    @Autowired
    private VipMapper vipMapper;


    @Override
    public void save(Vip vip) {
        vipMapper.insert(vip);
    }

    //分页查询
    @Override
    public PageBean page(String name, int page, int rows) {
        PageHelper.startPage(page, rows);
        List<Vip> vipList = vipMapper.list(name, page, rows);
        Page<Vip> p = (Page<Vip>) vipList;
        return new PageBean(p.getTotal(), p.getResult());
    }

    //根据ID查找
    @Override
    public Vip getVipById(Integer id) {
        return vipMapper.getVipById(id);
    }

    //修改会员信息
    @Override
    public void update(Vip vip) {
        vipMapper.update(vip);
    }

    //删除会员信息
    @Override
    public void delete(List<Integer> ids) {
        vipMapper.delete(ids);
    }


}
